package com.pachong.android.frameworkbase.customviews.ppw;

import android.graphics.drawable.BitmapDrawable;
import android.view.View;
import android.view.ViewGroup;
import android.widget.PopupWindow;

/**
 * 悬浮弹窗通用类
 *
 * @Author: PV
 * @E-mail: pengveivei@sina.cn
 * @CreateDate: 2016-08-04
 * @Version: 1.0.0
 */
public class CommonPopupWindow extends PopupWindow {

    private View mContentView;    //PopupWindow内部的View

    public CommonPopupWindow(View view, int width, int height) {
        super(view, width, height);
        mContentView = view;
        init();
    }

    public CommonPopupWindow(View view) {
        super(view, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        mContentView = view;
        init();
    }

    /**
     * 初始化悬浮弹窗
     */
    protected void init() {
        this.setFocusable(true);
        this.setOutsideTouchable(true);
        this.setBackgroundDrawable(new BitmapDrawable());
        this.setAnimationStyle(android.R.style.Animation_Toast);
    }

    /**
     * 显示悬浮窗
     */
    public void show(View anchor) {
        this.showAsDropDown(anchor, 0, 0);    //设置弹出的位置
    }


}
